<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      label-width="108px"
    >
      <el-form-item label="体检日期" prop="physicalDate">
        <el-date-picker
          clearable
          size="small"
          style="width: 200px"
          v-model="queryParams.physicalDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="幼儿姓名" prop="studentName">
        <el-input
          v-model="queryParams.studentName"
          placeholder="请输入姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table
      v-loading="loading"
      :data="studentList"
    >
      <el-table-column label="学生姓名" align="center" prop="studentName" />
      <el-table-column label="学生班级" align="center" prop="className" />
      <el-table-column label="体检时间" align="center" prop="physicalDate" />
      <el-table-column label="生日" align="center" prop="birthday" />
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <div>
            <el-button
              type="text"
              icon="el-icon-view"
              @click="detailBtn(scope.row)"
              >详情</el-button
            >
          </div>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { selectClazz } from "@/api/base/clazz";
import { listYdevice } from "@/api/base/device";
import {
  checkStudents,
  gethealthList,
  gethealthListInfo,
} from "@/api/base/ill";

export default {
  name: "gzt",
  dicts: ["sys_user_sex"],
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        checkDate: new Date(),
      },
      classList: [],
      // 遮罩层
      loading: true,
      total: 0,
    };
  },
  created() {
    //班级
    this.getQueryClazzList();
    this.getList();
  },
  methods: {
    resetQuery(){
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        checkDate: new Date(),
      }
      this.handleQuery()
    },
    handleQuery(){
      this.getList()
    },
    /** 查询学生列表 */
    async getList() {
      try {
        this.loading = true;
        const { rows, code, msg, total } = await gethealthList(
          this.queryParams
        );
        if (code === 200) {
          this.studentList = rows;
          this.total = total;
          this.loading = false;
        } else {
          this.$message.error(msg);
        }
      } catch (e) {
        console.log(e);
      }
    },
    detailBtn(row) {
      this.$router.push({ path: "/illcontrol/childrentj/reportmanagerDetail", query: {id:row.id} });
    },
    /** 查询班级列表 */
    async getQueryClazzList() {
      try {
        this.loading = true;
        const { rows } = await selectClazz();
        this.classList = rows.map((item) => {
          return {
            id: item.id,
            label: item.title,
          };
        });
        this.loading = false;
      } catch (e) {
        console.log(e);
      }
    },
  },
};
</script>
